## coding: utf-8
import os
from re import A
import sys

# 列举出该目录下的所有文件
def listAllFile(folder, size=-1):
    documents = os.listdir(folder)
    count = 0
    mincount = 0
    for document in documents:
        docPath = os.path.join(folder,document)
        if os.path.isdir(docPath):
            _count,_mincount = listAllFile(docPath, size)
            count+=_count
            mincount+=_mincount
        else:
            count+=1
            statinfo = os.stat(docPath)
            if size > 0:
                if statinfo.st_size <= size:
                    print(docPath,":",statinfo.st_size)
                    mincount += 1
            else:
                print(docPath,":",statinfo.st_size)
    
    return count,mincount
    
if __name__ == "__main__":
    if len(sys.argv) == 2:
        count,mincount = listAllFile(sys.argv[1])
        print("total files: ",count)
    elif len(sys.argv) == 3:
        count,mincount = listAllFile(sys.argv[1], int(sys.argv[2]))
        print("total files: ",count,"mincount: ", mincount)
        

